<template>
	<view class="activePage" :style="bgColor==''?'':'background-color: '+bgColor">
		<image class="topBanner" :src="topimgUrl" mode="widthFix"></image>
		<view class="ownerBox" @click="toDetail()"></view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				productPageForm: {
					activity_id:18
				},
				productList: [],
				newCouponLists: [],
				userInfo: {},
				activity_type:0,
				topimgUrl:'',
				bgColor:'',
				share_title:'',
				share_img:'',
				navbar_title:'',
				navbar_bgcolor:'',
				share:{
					title: '',
					imageUrl:'',
           		 },
			}
		},
		async onLoad(options) {
			await this.$onLaunched
			if(options.id){
				this.productPageForm.activity_id = options.id
			}
			this.getHttp();
		},
		onShow() {
			this.getHttp();
		},
		methods: {
			homePageFun(){
				uni.switchTab({
					url: '/pages/index/index'
				})
			},
			getHttp() {
				uni.$u.api.userInfo().then(res => {
					this.userInfo = res;
					this.getProduct();
				})
			},
			getProduct() {
				uni.$u.api.getActivityProduct(this.productPageForm).then(res => {
					console.log(res,'res')
					this.productList = res.list;
					this.activity_type = res.detail.activity_type;
					this.bgColor = res.detail.bgColor;
					this.topimgUrl = res.detail.imgUrl_path;
					this.share_title = res.detail.share_title;
					this.share_img = res.detail.share_img;
					this.navbar_title = res.detail.navbar_title;
					this.navbar_bgcolor = res.detail.navbar_bgcolor;
					this.share.title = res.detail.share_title
					this.share.imageUrl = res.detail.share_img_url
					if(this.navbar_title){
						uni.setNavigationBarTitle({
							title: this.navbar_title
						});
					}
					if(this.navbar_bgcolor){
						console.log(this.navbar_bgcolor,'this.navbar_bgcolor')
						uni.setNavigationBarColor({
							frontColor: '#000000',
							backgroundColor: this.navbar_bgcolor
						});
					}
				})
			},
			toDetail(){
				let item = this.productList?this.productList[0]:''
				let gourl = '/pages/categoty/product/product_active?id='+item.product.product_id+'&activity_product_id='+item.activity_product_id+'&restricted=1';
				// if(this.activity_type==1){
				// 	gourl = '/pages/categoty/product/product?id='+item.product.product_id;
				// }
				this.jump(gourl)
			},
			jump(url) {
				uni.navigateTo({
					url: url
				})
			},
		},
	}
</script>

<style lang="scss">
	.activePage {
		display: flex;
		flex-direction: column;
		align-items: center;
		min-height: 100vh;
		position: relative;

		.topBanner {
			width: 100%;
			// height: 1100rpx;
		}
		.ownerBox {
			width: 580rpx;
			height: 500rpx;
			position: absolute;
			top: 48%;
			left: 50%;
			transform: translate(-50%, -50%);
			// background: #b4b4b4;
			z-index: 99;
		}
	}
</style>